package com.homer.gps.track.adapters;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

import com.homer.gps.track.R;
import com.homer.gps.track.persist.PointModel;

public class PointsArrayAdaprer extends ArrayAdapter<PointModel>{
	
	private final String LOG_TAG = "PointsAdapter";

	private List<PointModel> points = null;
	private Activity context = null;
	
	public PointsArrayAdaprer(final Activity context, final int textViewResourceId, final List<PointModel> points) {
		super(context, textViewResourceId, points);
		this.context = context;
		this.points = points;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View rowView = convertView;
		
		if (rowView == null) {
			LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
			rowView = inflater.inflate(R.layout.points_list, parent, false);
		}
		
		TextView longitude = (TextView) rowView.findViewById(R.id.longitude);
		TextView latitude = (TextView) rowView.findViewById(R.id.latitude);
		PointModel point = points.get(position);
		
		longitude.setText(String.valueOf(point.getLongitude()));
		latitude.setText(String.valueOf(point.getLatitude()));
 
		return rowView;
	}
}
